import http from '@/utils/http'

const BASE_URL = '/sport/projectEntry'

export interface ProjectEntryResp {
  id: string
  projectId: string
  userId: string
  teamId: string
  userName: string
  teamName: string
  ProjectName: string
  createUserString: string
  updateUserString: string
}
export interface ProjectEntryDetailResp {
  id: string
  projectId: string
  userId: string
  teamId: string
  createTime: string
  updateTime: string
  createUser: string
  updateUser: string
  createUserString: string
  updateUserString: string
}
export interface ProjectEntryQuery {
  projectId: string
  userId: string
  teamId: string
  sort: Array<string>
}
export interface ProjectEntryPageQuery extends ProjectEntryQuery, PageQuery {}

/** @desc 查询报名列表 */
export function listProjectEntry(query: ProjectEntryPageQuery) {
  return http.get<PageRes<ProjectEntryResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询报名详情 */
export function getProjectEntry(id: string) {
  return http.get<ProjectEntryDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 报名参赛 */
export function addProjectEntry(projectId: string, type: string, gtype: string) {
  return http.get(`${BASE_URL}/apply/${projectId}/${type}/${gtype}`)
}

/** @desc 修改报名 */
export function updateProjectEntry(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除报名 */
export function deleteProjectEntry(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出报名 */
export function exportProjectEntry(query: ProjectEntryQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
